//
//  YYJLSearchController.m
//  YuanyangJinlou
//
//  Created by mac004 on 2017/1/3.
//  Copyright © 2017年 suli19910309@qq.com. All rights reserved.
//

#import "YYJLSearchController.h"

@interface YYJLSearchController ()<UITableViewDataSource,UITableViewDataSource>{
    UITableView  * myTableView;//搜索后显示view
    UIView       * noHistoryView;//暂无搜索历史
}

@end

@implementation YYJLSearchController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //[self setTitleView:@"搜索"];
 
    self.view.backgroundColor=UIColorFromHex(0xffffff);
    [self setBackItem];
    [self setRightBarItems];
    [self creatUI];

}
//-(void)setBackItem{
//    UIImage*img=[UIImage imageNamed:@"fanhui"];
//    UIButton*backBtn=[MyControl createButtonWithFrame:CGRectMake(15*PER_WIDTH, 28*PER_HEIGHT, img.size.width, img.size.height) ImageName:@"fanhui" Target:self Action:@selector(back) Title:@""];
//  
//
//    [self.view addSubview:backBtn];
//}
-(void)setRightBarItems{
    
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"搜索" style:UIBarButtonItemStylePlain target:self action:@selector(searchBtn)];
    [self.navigationItem.rightBarButtonItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:HSGBW3 size:15], NSFontAttributeName, nil] forState:UIControlStateNormal];
    [self.navigationItem.rightBarButtonItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:15], NSFontAttributeName, nil] forState:UIControlStateNormal];
    self.navigationItem.rightBarButtonItem.tintColor=UIColorFromHex(0x333333);
    
    
}

-(void)creatUI{
    UIImage*leftImg=[UIImage imageNamed:@"ico_sousuo"];
    UIImageView*leftView=[[UIImageView alloc]initWithFrame:CGRectMake(0*PER_WIDTH, 11*PER_HEIGHT, leftImg.size.width*PER_WIDTH, leftImg.size.height*PER_HEIGHT)];
    leftView.image=leftImg;
    UITextField*searchTF=[MyControl createTextFieldWithFrame:CGRectMake(55*PER_WIDTH, 27*PER_HEIGHT, 265*PER_WIDTH, 29*PER_HEIGHT) placeholder:@"请输入搜索内容" passWord:NO leftImageView:leftView rightImageView:nil];
    searchTF.backgroundColor=UIColorFromHex(0xebebeb);
    self.navigationItem.titleView =searchTF;
    
    //搜索按钮
    UIButton*searchBtn=[MyControl createButtonWithFrame:CGRectMake(searchTF.right+10*PER_WIDTH, searchTF.top, SCREEN_WIDTH-searchTF.right-25*PER_WIDTH, searchTF.height) ImageName:@"" Target:self Action:@selector(searchBtn) Title:@"搜索"];
    searchBtn.titleLabel.font=[UIFont systemFontOfSize:14.0*PER_WIDTH];
    [self.view addSubview:searchBtn];
    
    //搜索历史
    //1.星星图标
    UIImage*starImg=[UIImage imageNamed:@"e_sousuols"];
    UIImageView * starView=[MyControl createImageViewWithFrame:CGRectMake( 15*PER_WIDTH,64+15*PER_HEIGHT, starImg.size.width, starImg.size.height) ImageName:@"e_sousuols"];
    [self.view addSubview:starView];
    //2.搜索历史
    UILabel*historyLb=[MyControl createLabelWithFrame:CGRectMake(starView.right+8*PER_WIDTH, starView.top, 100, starView.height ) Font:14 Text:@"搜索历史"];
    historyLb.textColor=UIColorFromHex(0x333333);
    [self.view addSubview:historyLb];
    
    //3.清除历史
 
    UILabel*deleteLb=[MyControl createLabelWithFrame:CGRectZero Font:14 Text:@"清除历史"];
    CGFloat width = [deleteLb.text boundingRectWithSize:CGSizeMake(1000, 30) options: NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:deleteLb.font } context:nil].size.width;
    deleteLb.frame=CGRectMake(SCREEN_WIDTH-20*PER_WIDTH-width, historyLb.top, width, historyLb.height);
    deleteLb.textColor=UIColorFromHex(0x333333);
     [self.view addSubview:deleteLb];
    
    UIImage*deleteImg=[UIImage imageNamed:@"e_qingchuls"];
    UIImageView*deleteView=[MyControl createImageViewWithFrame:CGRectMake(deleteLb.left-8*PER_WIDTH-deleteImg.size.width, deleteLb.top, deleteImg.size.width, deleteImg.size.height) ImageName:@"e_qingchuls"];
    [self.view addSubview:deleteView];
    
    UIButton * deleteBtn=[MyControl createButtonWithFrame:CGRectMake(deleteView.left, deleteView.top, SCREEN_WIDTH-deleteView.left-20*PER_WIDTH, deleteView.height) ImageName:@"" Target:self Action:@selector(delete) Title:@""];
    deleteBtn.backgroundColor=[UIColor clearColor];
    [self.view addSubview:deleteBtn];
    
}
#pragma mark---搜索
-(void)searchBtn{
    
}
#pragma mark--删除搜索记录
-(void)delete{
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
